// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import Tool from "../framework/Tool";

const {ccclass, property} = cc._decorator;

@ccclass
export default class spiritMediator extends cc.Component {

    onBeginContact(contact, self, other) {
        if(other.node.group == "role"){
            this.node.destroy();
            cc.director.getPhysicsManager().enabled = false;
            Tool.loadPrefab("prefabs/conversationFrame",(res)=>{
                let view = cc.instantiate(res);
                view.zIndex = 1000;
                view.getComponent("conversationFrame").setCallBack(false,()=>{
                    cc.director.getPhysicsManager().enabled = true;
                });
                view.parent = cc.find("Canvas");
            })
        }

    }
}
